package com.example.account.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Author:汪彬彬
 * date:2024/11/11 15:13
 */
    @Component
    @Slf4j
    public class MessageReceiver {
        @RabbitHandler
        @RabbitListener(queues = RabbitmqConfig.DLK_QUEUE)
        public void onMessage(Message message){

            log.info("使用死信队列，收到消息:{}",new String(message.getBody()));
        }

//    @RabbitHandler
//    @RabbitListener(queues = RabbitmqConfig.DEMO_QUEUE)
//    public void onMessage1(Message message){
//        log.info("使用普通队列，收到消息:{}",new String(message.getBody()));
//    }

        @RabbitHandler
        @RabbitListener(queues = RabbitmqConfig.DMP_QUEUE)
        public void onMessage2(Message message){

            log.info("使用延迟插件，收到消息:{}",new String(message.getBody()));
        }
    }